/Accueil

Configurer Caddy 2

Ecrit le 1/11/2020

Installer

apk add caddy

Configurer le service

Référence: https://caddyserver.com/docs/

Obligé de passer à la version 2 de Caddy

Editer le fichier /etc/conf.d/caddy

caddy_opts="--config /etc/caddy/Caddyfile --adapter caddyfile"
error_log=/var/log/caddy/std.err
# ou pour logger avec syslog
error_logger=logger

Ancien fichier de configuration Caddy 1.x /etc/caddy/caddy.conf

mesnos.ovh {
    root /data/web/mesnos.ovh
    templates
    gzip
    tls legoff.laurent@gmail.com

    log /var/log/caddy/access.log {
        rotate_size 50  # Rotate after 50 MB
        rotate_age  90  # Keep rotated files for 90 days
        rotate_keep 20  # Keep at most 20 log files
        rotate_compress # Compress rotated log files in gzip format
    } 
    errors /var/log/caddy/error.log { 
        rotate_size 50  # Rotate after 50 MB
        rotate_age  90  # Keep rotated files for 90 days
        rotate_keep 20  # Keep at most 20 log files
        rotate_compress # Compress rotated log files in gzip format
    }   
}

backup.mesnos.ovh, http://backup.mesnos {
    root /data/backup
    browse
    gzip
    log /var/log/caddy/access.log 
    basicauth / llg blahblah
}

admin.mesnos.ovh {
    proxy / http://localhost:8080
    log /var/log/caddy/access.log 
}

pi1.mesnos.ovh, http://pi1.mesnos {
    proxy / http://192.168.0.15:3000
    log /var/log/caddy/access.log
}

timeseries.mesnos.ovh, http://timeseries.mesnos {
    proxy / http://localhost:8086
    log /var/log/caddy/access.log
}

minio.mesnos.ovh {
    proxy / http://localhost:9000
    log /var/log/caddy/access.log
}

livetrail.mesnos.ovh {
    root /home/zoe/gps-live-trail-app/
    gzip
    log /var/log/caddy/access.log
    header /manifest.webmanifest Content-Type application/json
    basicauth / llg blahblah
}

dojoplouzane.mesnos.ovh {
    proxy / http://localhost:9090
    log /var/log/caddy/access.log
}

llgmusic.net {
    root /home/zoe/llgmusic.net/
    gzip
    tls legoff.laurent@gmail.com

    log /var/log/caddy/access.log {
        rotate_size 50  # Rotate after 50 MB
        rotate_age  90  # Keep rotated files for 90 days
        rotate_keep 20  # Keep at most 20 log files
        rotate_compress # Compress rotated log files in gzip format
    }
    errors /var/log/caddy/error.log {
        rotate_size 50  # Rotate after 50 MB
        rotate_age  90  # Keep rotated files for 90 days
        rotate_keep 20  # Keep at most 20 log files
        rotate_compress # Compress rotated log files in gzip format
    }
#  git github.com/llgcode/llgmusic.net {
#    hook /webhook
#  }
}

songbook.llgmusic.net {                                          
    proxy / http://localhost:8000
    gzip                                
    log /var/log/caddy/access.log                                
} 

Nouveau fichier de config /etc/caddy/Caddyfile

# Caddy's configuration file
# see: https://caddyserver.com/docs/caddyfile

mesnos.ovh {
    root * /data/web/mesnos.ovh
    file_server
    tls legoff.laurent@gmail.com
    encode zstd gzip
    templates
    log {
        output file /var/log/caddy/access.log
    }
}


admin.mesnos.ovh {
    reverse_proxy /* http://localhost:8080
    encode zstd gzip
    log {
        output file /var/log/caddy/access.log
    }
}

dojoplouzane.mesnos.ovh {
    reverse_proxy /* http://localhost:9090
    encode zstd gzip
    log {
        output file /var/log/caddy/access.log
    }
}

llgmusic.net {
    root * /home/zoe/llgmusic.net/
    file_server
    encode zstd gzip
    tls legoff.laurent@gmail.com
    log {
        output file /var/log/caddy/access.log
    }
}

songbook.llgmusic.net {                                          
    reverse_proxy /* http://localhost:8000
    encode zstd gzip                       
    log {
        output file /var/log/caddy/access.log
    }                               
} 
    
    
-- Laurent